﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sy2_10
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int[] num;
        string statisticsStr;
        private void button1_Click(object sender, EventArgs e)
        {
            int n =int.Parse(textBox1.Text);
            int min = int.Parse(textBox2.Text);
            int max = int.Parse(textBox3.Text);
            num= new int[n];
            int even = 0, odd = 0, positive = 0, negative = 0;
            Random rand = new Random();
            for (int i = 0; i < n; i++)
            {
                num[i] = rand.Next(min,max+1);
                if (num[i] > 0) positive++;
                if (num[i]<0 )negative++;
                if(num[i]%2 ==0) odd++;
                else even++;
            }
            statisticsStr = "\r\n\r\n正数" + positive + "个   负数" + negative + "个    奇数" + even + "个   偶数" + odd + " 个 ";
            textBox4.Text = String.Join("    ", num);
            textBox4.Text = statisticsStr;
            button2.Enabled = true;
            button2.Text = "排序";

        }

        private void button2_Click(object sender, EventArgs e)
        {
            if(button2.Text == "排序")
            {
                Array.Sort(num);
                button2.Text = "排序";
            }
            else
            {
                Array.Reverse(num);
                button2.Text = "逆序";
            }
            textBox4.Text = String.Join("   ", num);
            textBox4.Text += statisticsStr;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            button2.Enabled=false;
        }
    }
}
